<?php

namespace app\index\controller\trade;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\index\model\UM as UM;
use app\index\service\TradeInfoService;
use think\APP;
use think\Request as Request;

/**
 * TradeInfo 控制器
 * Class TradeInfo
 * @package app\index\controller\trade;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\trade\TradeInfo
 */
class TradeInfo
{
    // 请求参数
    private Request $request;

    // service
    private TradeInfoService $service;

    public function __construct(Request $request, TradeInfoService $tradeInfoService)
    {
        $this->request = $request;
        $this->service = $tradeInfoService;
    }

    /**
     * 详情
     * @param UM $user
     * @return ApiResponse
     * @url /trade/trade_info/read
     */
    public function read(UM $user): ApiResponse
    {
        $request     = $this->request;

        $id = $request->param('id');

        if(!CheckUtil::isId($id)){
            return ApiResponse::fail('缺少id参数');
        }

        return ApiResponse::success($this->service->read($user, $id));
    }

}
